//
//  PayTrusteesViewController.m
//  Fangmm
//
//  Created by ChaoZhou on 16/3/22.
//  Copyright © 2016年 com.fangmm. All rights reserved.
//

#import "PayTrusteesViewController.h"
#import "PayTrustFeeViewController.h"
#import "House.h"
#import <UIImageView+WebCache.h>
#import "HomePageUser.h"
#import "Utility.h"
#import "Constants.h"
#import <MobClick.h>
@interface PayTrusteesViewController ()
{
    House *majorHouse;
}

@end

@implementation PayTrusteesViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"支付保证金页面"];//("PageOne"为页面名称，可自定义)
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"支付保证金页面"];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    majorHouse = (House *)[self.scheduleInfo.scheduleArray firstObject];
    if (majorHouse.houseCover == nil || [majorHouse.houseCover isEqualToString:@""])
    {
        [self.houseImage setImage:[UIImage imageNamed:@"Non_HP"]];
    }
    else
    {
         [self.houseImage sd_setImageWithURL:[NSURL URLWithString:majorHouse.houseCover] placeholderImage:[UIImage imageNamed:@"Non_HP"]];
    }
    self.houseCommunityLabel.text = majorHouse.houseCommunity;
    NSString *dateLabelStr = [NSString stringWithFormat:@"%@%@",majorHouse.createTime,_scheduleInfo.leader == YES ? @"成为室长":@"加入房间"];
    self.dateLabel.text = dateLabelStr;
    for (HomePageUser *user in _scheduleInfo.menberArray)
    {
        self.memberLabel.text = [NSString stringWithFormat:@"%d/%d",majorHouse.houseRoomNum,majorHouse.houseRoomNum];
        if ([user.userId isEqualToString:[Utility getObjectForKey:kUserId]])
        {
            self.roomNameLabel.text = user.roomName;
            self.roomPriceLabel.text = [NSString stringWithFormat:@"%d元",(user.rent)/100];
        }
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)payButtonClick:(UIButton *)sender
{
    PayTrustFeeViewController *payTrustFeeVC = [[PayTrustFeeViewController alloc]init];
    payTrustFeeVC.scheduleId = majorHouse.scheduleId;
    [self presentViewController:payTrustFeeVC animated:YES completion:nil];
}

- (IBAction)closeButtonClick:(UIButton *)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
